/*
 * @Author: 一路向阳 tt_sunzhenfeng@163.com
 * @Date: 2024-05-26 17:36:32
 * @LastEditors: 一路向阳 tt_sunzhenfeng@163.com
 * @LastEditTime: 2024-05-27 00:35:05
 * @FilePath: \vue3_nuxt_demo\apis\note.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { useHttpFetch, type IFetchOptions } from '@/composables/useHttpFetch';

// 获取文集列表
interface INoteList extends IFetchOptions {
  pageNo: number;
  pageSize: number;
}
export const noteList = (opt: INoteList) => {
  return useHttpFetch('/api/note', {
    ...opt,
    method: 'GET',
    key: 'noteList'
  });
}

// 新建文章
interface INote extends IFetchOptions {
  notebookId: number;
}
export const addNote = (opt: INote) => {
  return useHttpFetch('/api/note', {
    ...opt,
    method: 'POST',
    key: 'addNote'
  });
}

// 更新文章
interface IUpdateNote extends IFetchOptions {
  noteId: number;
  title: string;
  content_md: string;
  state: number;
}
export const updateNote = (opt: IUpdateNote) => {
  return useHttpFetch('/api/note', {
    ...opt,
    method: 'PUT',
    key: 'updateNote'
  });
}

// 删除文章
interface IDeleteNote extends IFetchOptions {
  noteId: number;
}
export const deleteNote = (opt: IDeleteNote) => {
  return useHttpFetch('/api/note', {
    ...opt,
    method: 'DELETE',
    key: 'deleteNote'
  });
}